package test;

import static org.junit.Assert.*;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Scanner;

import org.junit.Test;

public class test 
{
//
//	@Test
//	public void testPrintWriter() {
//		String fileName = "d:/Test.data";
//		int count = 10000000;
//		PrintWriter pw = null;
//		try{
//			pw = new PrintWriter(fileName);
//			for(int i = 0;i< count;i++){
//				pw.println(1);
//			}
//		}catch(FileNotFoundException e){
//			e.printStackTrace();
//		}finally{
//			pw.close();
//		}
//	}
 
//	@Test
//     public  void  testBufferedWriter() throws IOException 
//	{  
//		       FileWriter fw = new FileWriter("d:/uffered.data");  
//		        BufferedWriter bufw = new BufferedWriter(fw);
//		        int count = 10000000;
//				for(int i = 0;i< count;i++){
//		       bufw.write("1"); 
//		        bufw.newLine();  } 
//		        bufw.flush();  
//		        bufw.close();     
//		   }  
//}

	
	@Test
	public void testBufferedRead() 
	{
		String fileName = "d:/Test.data";
		BufferedReader br = null;
		try
		{
			br = new BufferedReader(new FileReader(new File(fileName)));
					while(br.readLine()!=null){};				
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				br.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
			



	
@Test
public void testScanner()
{
	     String fileName = "d:/Test.data";
		  Scanner scanner=null;
		  try
		  {
		      scanner = new Scanner(new File(fileName));
		      String line=scanner.nextLine();
		    	  while(scanner.hasNextLine()){
		    		  scanner.nextLine();}
		  }
		  catch(FileNotFoundException e)
		  {
		   e.printStackTrace();
		   }
		      finally{
		    	  scanner.close();
		      }		  
		 
}
}





